Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Remove context from capv customized controller context #2431

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

zhanggbj
Copy link
Contributor

@zhanggbj zhanggbj commented Oct 13, 2023

What this PR does / why we need it:
Remove context from capv customized controller context, also get rid of containedctx exceptions.
This is part of #2295.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of
#2295
#2384

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 13, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 13, 2023
@zhanggbj zhanggbj mentioned this pull request Oct 13, 2023
18 tasks
@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (013ce3f) 62.65% compared to head (fa689e1) 62.69%.
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2431      +/-   ##
==========================================
+ Coverage   62.65%   62.69%   +0.03%     
==========================================
  Files         122      122              
  Lines        8770     8763       -7     
==========================================
- Hits         5495     5494       -1     
+ Misses       2877     2872       -5     
+ Partials      398      397       -1     
Files Coverage Δ
controllers/vspherevm_controller.go 63.76% <100.00%> (ø)
pkg/clustermodule/util.go 100.00% <100.00%> (ø)
pkg/context/controller_manager_context.go 75.00% <ø> (ø)
pkg/context/fake/fake_controller_context.go 100.00% <100.00%> (ø)
...kg/context/fake/fake_controller_manager_context.go 100.00% <ø> (ø)
pkg/context/vm_context.go 100.00% <100.00%> (ø)
pkg/context/vspheredeploymentzone_context.go 84.61% <100.00%> (ø)
pkg/manager/manager.go 84.41% <100.00%> (-0.20%) ⬇️
pkg/services/govmomi/cluster/service.go 78.57% <ø> (ø)
pkg/services/govmomi/context.go 0.00% <ø> (ø)
... and 11 more

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhanggbj zhanggbj changed the title [WIP] 🌱 Remove context from capv customized controller context 🌱 Remove context from capv customized controller context Oct 13, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 13, 2023
@killianmuldoon
Copy link
Contributor

/test

@k8s-ci-robot
Copy link
Contributor

@killianmuldoon: The /test command needs one or more targets.
The following commands are available to trigger required jobs:

  • /test pull-cluster-api-provider-vsphere-conformance-main
  • /test pull-cluster-api-provider-vsphere-e2e-full-main
  • /test pull-cluster-api-provider-vsphere-e2e-main
  • /test pull-cluster-api-provider-vsphere-test-integration-main
  • /test pull-cluster-api-provider-vsphere-test-main
  • /test pull-cluster-api-provider-vsphere-verify-main

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-provider-vsphere-apidiff-main

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-provider-vsphere-apidiff-main
  • pull-cluster-api-provider-vsphere-e2e-main
  • pull-cluster-api-provider-vsphere-test-integration-main
  • pull-cluster-api-provider-vsphere-test-main
  • pull-cluster-api-provider-vsphere-verify-main

In response to this:

/test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/test pull-cluster-api-provider-vsphere-e2e-full-main

pkg/context/fake/fake_cluster_context.go Outdated Show resolved Hide resolved
pkg/context/fake/fake_cluster_context.go Outdated Show resolved Hide resolved
pkg/context/fake/fake_cluster_context.go Outdated Show resolved Hide resolved
pkg/context/fake/fake_vm_context.go Outdated Show resolved Hide resolved
pkg/context/fake/fake_vm_context.go Outdated Show resolved Hide resolved
pkg/manager/manager.go Show resolved Hide resolved
@zhanggbj
Copy link
Contributor Author

@chrischdi Thanks for your review, all comments are addressed, it's ready for a second look.

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some last nits, but that should be it 🎉

controllers/serviceaccount_controller_intg_test.go Outdated Show resolved Hide resolved
test/helpers/vmware/unit_test_context.go Outdated Show resolved Hide resolved
test/helpers/vmware/unit_test_context.go Outdated Show resolved Hide resolved
@Ankitasw
Copy link
Member

/retest

@zhanggbj
Copy link
Contributor Author

/test pull-cluster-api-provider-vsphere-test-main

1 similar comment
@zhanggbj
Copy link
Contributor Author

/test pull-cluster-api-provider-vsphere-test-main

@chrischdi
Copy link
Member

Seems like somethings broken. Failed 3 times in a row at the same test.

@zhanggbj
Copy link
Contributor Author

The failure cannot be reproduced locally by make test.

@chrischdi
Copy link
Member

/lgtm
/approve
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 23, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 23, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 106aacf81c92bda187fe7571e29641e35e5f5dee

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 23, 2023
@chrischdi
Copy link
Member

hold for if @sbueringer or @killianmuldoon want to review.

@chrischdi
Copy link
Member

/retest

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 24, 2023
Remove context from capv customized controller context, also get rid of containedctx
exceptions.

Signed-off-by: Gong Zhang <[email protected]>
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Oct 25, 2023

@zhanggbj: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-vsphere-apidiff-main fa689e1 link false /test pull-cluster-api-provider-vsphere-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@zhanggbj
Copy link
Contributor Author

/test pull-cluster-api-provider-vsphere-test-main

@chrischdi
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 25, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: f4bb6be1c019ffdef1a60d099e59d8262bb4f497

@sbueringer
Copy link
Member

Thx!

/lgtm
/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 25, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi, sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [chrischdi,sbueringer]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sbueringer
Copy link
Member

sbueringer commented Oct 25, 2023

@chrischdi @zhanggbj Sorry I have a huge backlog right now. Can one of you audit for similar cases across the code base?

Basically when we start goroutines in reconcilers that should continue independent of the current Reconcile we should not passthrough the context and stop the goroutine if that context is Done.

A concrete bug we would get is that we wouldn't reconcile again (before the resyncPeriod) after a task is finished (if a goroutine is waiting for task finish) if that context gets canceled (e.g. by controller-runtime)

But on the other side we of course have the risk of leaking goroutines if the task never finishes. This seems to be a consequence of the current design.

Let's audit to not stop the goroutines based on passed through context's for now and let's create an issue to discuss if we want to maybe put a timeout on the contexts used in those goroutines to avoid leaking goroutines (or some alternative if we have other ideas)

P.S. If I understand the previous code (e.g. release-1.8) correctly context.Done only happened if the ControllerManagerContext.context was canceled. But this context was just a context.Background(), so I guess it never got canceled. So we don't lose anything if we get rid of the ctx.Done()'s for now

@k8s-ci-robot k8s-ci-robot merged commit 5211b8e into kubernetes-sigs:main Oct 25, 2023
15 of 16 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Oct 25, 2023
@zhanggbj
Copy link
Contributor Author

@sbueringer It makes sense to me, I just opened an issue based on your input to track it, we could discuss more there #2465

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants